package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.CalculateRuleEntity;
import com.jinmdz.fmis.mapper.mapper.provider.CalculateRuleProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 计算规则Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface CalculateRuleMapper {

    /**
     * 增加CalculateRule
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = CalculateRuleProvider.class, method = "insertCalculateRule")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertCalculateRule(@Param("entity") CalculateRuleEntity entity);

    /**
     * 删除CalculateRule
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update calculate_rule set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForCalculateRule(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改CalculateRule
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = CalculateRuleProvider.class, method = "updateCalculateRule")
    void updateCalculateRule(@Param("entity") CalculateRuleEntity entity);

    /**
     * 查询CalculateRule实体
     *
     * @param id 主键
     * @return CalculateRuleEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,rule_code,rule_type,rule_version,call_explanation,rule_describe,disable_state,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from calculate_rule where id = #{id} and deleted = 0 limit 1 ")
    CalculateRuleEntity getCalculateRuleById(@Param("id") Integer id);

    /**
     * 查询CalculateRule列表
     *
     * @param entity 数据实体
     * @return CalculateRuleEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = CalculateRuleProvider.class, method = "listCalculateRule")
    ArrayList<CalculateRuleEntity> listCalculateRule(@Param("entity") CalculateRuleEntity entity);
}